import { userProfilesApi } from '../../JingPinApi/api'
export default {
    namespaced: true,
    state: {
        nickName: '未登录',
        coin: '--',
        headImg: require('../../img/userImg.f8bbec5e.png'),
        cartTotal: 0
    },
    getters: {
    },
    mutations: {
        changUserInfo(state, payload) {
            state.nickName = payload.userInfo.nickName
            state.coin = payload.userInfo.coin
            state.headImg = payload.userInfo.headImg
            state.cartTotal = payload.cartTotal
        },
        initUserInfo(state, payload) {
            state.nickName = '未登录',
                state.coin = '--',
                state.headImg = require('../../img/userImg.f8bbec5e.png'),
                state.cartTotal = 0
        }
    },
    actions: {
        async asyncchangUserInfo({ commit }, payload) {
            let res = await userProfilesApi()
            console.log('userProfilesApi', res.data);
            commit('changUserInfo', res.data)
        }
    }

}